<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <input type="text" id="input">
  <p id="p"></p>
  <script>
    let obj1 = {name: 'Jack', age: 18}
    // Object.defineProperty(obj1, 'name', {
    //   // 是否可以删除
    //   configurable: false,
    //   // 是否可以修改
    //   writable: false
    // })
    Object.defineProperty(obj1, 'name', {
      set(val) {
        p.innerHTML = val;
      },
      get() {
        console.log(777);
      }
    })
    input.oninput = function(e) {
      obj1.name = e.target.value;
    }
  </script>
</body>
</html>